﻿using System.Collections.Generic;

namespace LNet
{
    /// <summary>
    /// 包
    /// </summary>
    public class Response : Packet
    {
        public int RequestClientID = 0;
        public List<int> RecieveClientIDs { get; set; }

        public PacketKey ResponseCode = PacketKey.None;

        public SubCode ResponseSubCode = SubCode.None;

        /// <summary>
        /// 返回操作结果 成功 失败 错误等
        /// </summary>
        public ReturnCode ReturnCode = ReturnCode.None;

        /// <summary>
        /// 返回操作信息描述 失败的原因
        /// </summary>
        public string RetrunMessage = "";

        public Response()
        {

        }
        public Response(PacketKey key)
        {
            ResponseCode = key;
        }

        public Response(PacketKey key, object data)
        {
            ResponseCode = key;
            DataObject = data;
        }
        /// <summary>
        ///将请求变为响应，并且返回代码为 Success
        /// </summary>
        /// <param name="r"></param>
        public Response(Request r)
        {
            RecieveClientIDs = r.RecieveClientIDs;
            ResponseCode = r.RequestCode;
            ResponseSubCode = r.RequestSubCode;
            ReturnCode = ReturnCode.Success;
            DataObject = r.DataObject;
        }
        public Response(PacketKey key, SubCode subCode)
        {
            ResponseCode = key;
            ResponseSubCode = subCode;
        }


        public Response(PacketKey key, SubCode subCode, ReturnCode returnCode, string returnMsg, object ObjParameter = null)
        {
            ResponseCode = key;
            ResponseSubCode = subCode;
            ReturnCode = returnCode;
            RetrunMessage = returnMsg;
            DataObject = ObjParameter;
        }

    }

}